﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace CheemsControl.Demo.Views.UserControl
{
    /// <summary>
    /// MessageTimelineWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MessageTimelineWindow : Window
    {
        public MessageTimelineWindow()
        {
            InitializeComponent();
            this.MessageTimeline.Source = new Models.MessageTimeline.MessageDatas();
            Task.Run(async () =>
            {
                for (int i = 0; i < 100; i++)
                {
                    int num = i;
                    await Task.Delay(i * 1000);
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        this.MessageTimeline.Source.AddMessage(new Models.SingleMessage()
                        {
                            title = $"Title{num.ToString()}",
                            tips = num.ToString(),
                            message = $"Message{num.ToString()}",
                            type = (i%3==0)? Models.Common.AlarmLevel.Alarm : ((i%3==1) ? Models.Common.AlarmLevel.Warning : Models.Common.AlarmLevel.None)
                        });
                    });
                }
            });

        }
    }
}
